import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

// 动态加载modules
const modules = {}
const files = require.context('./modules', true, /\.js$/)
files.keys().map(key => {
  const moduleName = key.replace(/(\.\/|\.js)/g, '')
  const module = require(`./modules/${moduleName}.js`)
  modules[moduleName] = module.default
})

console.log(modules)

const store = new Vuex.Store({
  state: {},
  mutations: {},
  actions: {},
  getters: {},
  modules: modules
})

export default store
